<%@ page import="com.goal98.team.Constants" %>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="main"/>
    <title><g:message code="team.edit" default="Edit Team"/></title>
  </head>
  <body>
    <div class="nav">
    %{--<span class="menuButton"><a class="home" href="${createLinkTo(dir: '')}"><g:message code="home" default="Home" /></a></span>--}%
      <g:ifAnyGranted role="${Constants.ROLE_ADMIN}">
        <span class="menuButton"><g:link class="list" controller="team" action="list"><g:message code="team.list" default="Team List"/></g:link></span>
        <span class="menuButton"><g:link class="create" controller="team" action="create"><g:message code="team.new" default="New Team"/></g:link></span>
      </g:ifAnyGranted>
    </div>
    <div class="body">
      <h1><g:message code="team.edit" default="Edit Team"/></h1>
      <g:if test="${flash.message}">
        <div class="message"><g:message code="${flash.message}" args="${flash.args}" default="${flash.defaultMessage}"/></div>
      </g:if>
      <g:hasErrors bean="${teamInstance}">
        <div class="errors">
          <g:renderErrors bean="${teamInstance}" as="list"/>
        </div>
      </g:hasErrors>
      <g:form method="post">
        <g:hiddenField name="id" value="${teamInstance?.id}"/>
        <g:hiddenField name="version" value="${teamInstance?.version}"/>
        <div class="dialog">
          <table>
            <tbody>

              %{--<tr class="prop">
                  <td valign="top" class="name">
                      <label for="dateCreated"><g:message code="team.dateCreated" default="Date Created" />:</label>
                  </td>
                  <td valign="top" class="value ${hasErrors(bean: teamInstance, field: 'dateCreated', 'errors')}">
                      <g:datePicker name="dateCreated" value="${teamInstance?.dateCreated}" precision="minute" ></g:datePicker>
                  </td>
              </tr>

              <tr class="prop">
                  <td valign="top" class="name">
                      <label for="lastUpdated"><g:message code="team.lastUpdated" default="Last Updated" />:</label>
                  </td>
                  <td valign="top" class="value ${hasErrors(bean: teamInstance, field: 'lastUpdated', 'errors')}">
                      <g:datePicker name="lastUpdated" value="${teamInstance?.lastUpdated}" precision="minute" ></g:datePicker>
                  </td>
              </tr>--}%

              %{--<tr class="prop">
                <td valign="top" class="name">
                  <label for="members"><g:message code="team.members" default="Members"/>:</label>
                </td>
                <td valign="top" class="value ${hasErrors(bean: teamInstance, field: 'members', 'errors')}">

                  <ul>
                    <g:each var="m" in="${teamInstance?.members?}">
                      <li><g:link controller="person" action="show" id="${m.id}">${m?.encodeAsHTML()}</g:link></li>
                    </g:each>
                  </ul>
                  <g:link controller="person" params="['team.id':teamInstance?.id]" action="create">Add Person</g:link>

                </td>
              </tr>--}%

              <tr class="prop">
                <td valign="top" class="name">
                  <label for="name"><g:message code="team.name" default="Name"/>:</label>
                </td>
                <td valign="top" class="value ${hasErrors(bean: teamInstance, field: 'name', 'errors')}">
                  <input type="text" id="name" name="name" value="${fieldValue(bean: teamInstance, field: 'name')}"/>
                </td>
              </tr>

              %{--<tr class="prop">
                <td valign="top" class="name">
                  <label for="teamAdmins"><g:message code="team.teamAdmins" default="Team Admins"/>:</label>
                </td>
                <td valign="top" class="value ${hasErrors(bean: teamInstance, field: 'teamAdmins', 'errors')}">

                </td>
              </tr>--}%

            </tbody>
          </table>
        </div>
        <div class="buttons">
          <g:ifAnyGranted role="${Constants.ROLE_ADMIN + ',' + Constants.ROLE_TEAM_ADMIN}">
            <span class="button"><g:actionSubmit class="save" action="update" value="${message(code: 'update', 'default': 'Update')}"/></span>
          </g:ifAnyGranted>
          <g:ifAnyGranted role="${Constants.ROLE_ADMIN}">
            <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'delete', 'default': 'Delete')}" onclick="return confirm('${message(code: 'delete.confirm', 'default': 'Are you sure?')}');"/></span>
          </g:ifAnyGranted>
        </div>
      </g:form>
    </div>
  </body>
</html>
